<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>查看员工</title>
	<link rel="stylesheet" href="../layui/css/layui.css" type="text/css" />
	<style type="text/css">label span {color: red;}</style>
</head>
<body>
	<form class="layui-form" style="margin-top: 15px" lay-filter="employee">
		<div class="layui-form-item">
			<label class="layui-form-label">员工名：</label>
			<input type="text" class="layui-input layui-input-inline" name="empName" readonly />
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">邮箱：</label>
			<input type="text" class="layui-input layui-input-inline" name="email" readonly />
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">性别：</label>
			<input type="text" name="sex" class="layui-input layui-input-inline" readonly />
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">部门：</label>
			<input type="text" class="layui-input layui-input-inline" name="deptName" readonly />
		</div>
		<div class="layui-form-item" style="text-align: center">
			<button class="layui-btn layui-btn-lg" type="button" id="close">
				<i class="layui-icon layui-icon-close"></i>关闭
			</button>
		</div>
	</form>
</body>
<script src="../jquery/jquery.min.js"></script>
<script src="../layui/layui.js"></script>
<script src="../common.js"></script>
<script>
	var index = parent.layer.getFrameIndex(window.name);
	var empId = getUrlParam("empId");
	layui.use("form", function () {
		var form = layui.form;
		form.render();
		
		$.ajax({
			url: baseUrl + "depts",
			success: function (res) {
				$.each(res.data.list, function (index, item) {
					$("#dId").append("<option value='"+item.deptId+"'>"+item.deptName+"</option>");
				});
				form.render();
				$.ajax({
					url: baseUrl + "emp/" + empId,
					success: function (res) {
						var data = res.data;
						form.val("employee", {
							"empId": data.empId,
							"empName": data.empName,
							"email": data.email,
							"sex": data.sex,
							"deptName": data.department.deptName
						});
						form.render();
					}
				});
			}
		});
	});
	
	$("#close").on("click", function () {parent.layer.close(index);});
</script>
</html>